<template>
  <div class="app-container">
    <el-card class="box-card">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"  label-width="70px">
        <el-form-item label="姓名" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入姓名"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
<!--        <el-form-item label="身份证号" prop="idNumber" v-show="showSearch">
          <el-input
            v-model="queryParams.idNumber"
            placeholder="请输入身份证号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>-->
<!--        <el-form-item label="工作单位" prop="workPlace" v-show="showSearch">
          <el-select v-model="queryParams.workPlace" placeholder="请选择工作单位" clearable>
            <el-option
              v-for="dict in dict.type.yh_gas_station"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>-->
        <el-form-item label="工号" prop="userName" >
          <el-input
            v-model="queryParams.userName"
            placeholder="请输入工号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
<!--        <el-form-item label="手机号" prop="phone" v-show="showSearch">
          <el-input
            v-model="queryParams.phone"
            placeholder="请输入手机号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>-->
<!--        <el-form-item label="职位" prop="posts" v-show="showSearch">
          <el-select v-model="queryParams.posts" placeholder="请选择职位" clearable>
            <el-option
              v-for="dict in dict.type.yh_posts"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>-->
<!--        <el-form-item label="出生日期" prop="birth" v-show="showSearch">
          <el-date-picker clearable
                          v-model="queryParams.birth"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择出生日期" style="width: 94%;">
          </el-date-picker>
        </el-form-item>-->

        <el-form-item label="钢瓶瓶号" prop="cylinderNumber">
          <el-input
            v-model="queryParams.cylinderNumber"
            placeholder="请输入钢瓶瓶号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
<!--        <el-form-item label="钢瓶状态" prop="cylinderStatus" v-show="showSearch">
          <el-select v-model="queryParams.cylinderStatus" placeholder="请选择钢瓶状态" clearable>
            <el-option
              v-for="dict in dict.type.yh_cylinder_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>-->
        <el-form-item label="应充介质" prop="gasMedia"  v-show="showSearch">
          <el-select v-model="queryParams.gasMedia" placeholder="请选择应充介质" clearable>
            <el-option
              v-for="dict in dict.type.yh_medium"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>

<!--        <el-form-item label="钢瓶报废日期" prop="scrapDate" v-show="showSearch">
          <el-date-picker clearable
                          v-model="queryParams.scrapDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择钢瓶报废日期" style="width: 94%;">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="钢瓶容积" prop="volume" label-width="85px" v-show="showSearch">
          <el-input
            v-model="queryParams.volume"
            placeholder="请输入钢瓶容积"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="所属气站" prop="belongingGasStation" v-show="showSearch">
          <el-select v-model="queryParams.belongingGasStation" placeholder="请选择所属气站" clearable>
            <el-option
              v-for="dict in dict.type.yh_gas_station"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>-->

   <el-form-item label="充装气站" prop="fillingStation"  >
          <el-select v-model="queryParams.fillingStation" placeholder="请选择充装气站" clearable>
            <el-option
              v-for="dict in dict.type.yh_gas_station"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="充装介质" prop="fillingMedium" >
          <el-select v-model="queryParams.fillingMedium" placeholder="请选择充装介质" clearable>
            <el-option
              v-for="dict in dict.type.yh_medium"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
<!--        <el-form-item label="钢瓶重量" prop="weight" v-show="showSearch">
          <el-input
            v-model="queryParams.weight"
            placeholder="请输入钢瓶重量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item label="钢瓶生产日期" prop="manufactureDate" v-show="showSearch">
          <el-date-picker clearable
                          v-model="queryParams.manufactureDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择钢瓶生产日期" style="width: 94%;" >
          </el-date-picker>
        </el-form-item>-->


        <el-form-item label="充装时间" prop="note1"  v-show="showSearch" >
          <el-date-picker clearable
                          v-model="queryParams.note1"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择充装时间" style="width: 94%;">
          </el-date-picker>
        </el-form-item>

<!--        <el-form-item label="用户ID" prop="userId">
          <el-input
            v-model="queryParams.userId"
            placeholder="请输入用户ID"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单位ID" prop="deptId">
          <el-input
            v-model="queryParams.deptId"
            placeholder="请输入单位ID"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>-->

        <div style="text-align: right;margin-right:-9px;">
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </div>
      </el-form>

      <el-row :gutter="10" class="mb8">
<!--        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['zzy:filling:add']"
          >新增</el-button>
        </el-col>-->
<!--        <el-col :span="1.5">
          <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['zzy:filling:edit']"
          >修改</el-button>
        </el-col>-->
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['zzy:filling:remove']"
          >删除</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['zzy:filling:export']"
          >导出
          </el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
      </el-row>

      <el-table v-loading="loading" :data="fillingList" border @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column type="index" label="序号" width="55" :index="indexMethod" align="center"
                         v-if="columns[0].visible"/>
        <el-table-column label="姓名" align="center" prop="name" v-if="columns[1].visible"/>
        <el-table-column label="身份证号" align="center" prop="idNumber" v-if="columns[2].visible"/>
        <el-table-column label="工作单位" align="center" prop="workPlace" v-if="columns[3].visible">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yh_gas_station" :value="scope.row.workPlace"/>
          </template>
        </el-table-column>
         <el-table-column label="性别" align="center" prop="sex" v-if="columns[4].visible">
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"/>
                </template>
              </el-table-column>
        <el-table-column label="工号" align="center" prop="userName" v-if="columns[5].visible"/>
        <el-table-column label="手机号" align="center" prop="phone" v-if="columns[6].visible"/>
        <el-table-column label="职位" align="center" prop="posts" v-if="columns[7].visible">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yh_posts" :value="scope.row.posts"/>
          </template>
        </el-table-column>
            <el-table-column label="出生日期" align="center" prop="birth" width="180" v-if="columns[8].visible">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.birth, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
        <el-table-column label="钢瓶瓶号" align="center" prop="cylinderNumber" v-if="columns[9].visible"/>
        <el-table-column label="应充介质" align="center" prop="gasMedia" v-if="columns[10].visible">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yh_medium" :value="scope.row.gasMedia"/>
          </template>
        </el-table-column>
        <el-table-column label="钢瓶状态" align="center" prop="cylinderStatus" v-if="columns[11].visible">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yh_cylinder_status" :value="scope.row.cylinderStatus"/>
          </template>
        </el-table-column>
        <el-table-column label="钢瓶重量" align="center" prop="weight" v-if="columns[12].visible"/>
        <el-table-column label="钢瓶容积" align="center" prop="volume" v-if="columns[13].visible"/>
        <el-table-column label="所属气站" align="center" prop="belongingGasStation" v-if="columns[14].visible">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yh_gas_station" :value="scope.row.belongingGasStation"/>
          </template>
        </el-table-column>
        <el-table-column label="钢瓶生产日期" align="center" prop="manufactureDate" width="180"
                         v-if="columns[15].visible">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.manufactureDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="钢瓶报废日期" align="center" prop="scrapDate" width="180" v-if="columns[16].visible">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.scrapDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="气瓶检验时间" align="center" prop="inspectionTime" width="180" v-if="columns[17].visible">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.inspectionTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="下次检验时间" align="center" prop="nextInspectionTime" width="180" v-if="columns[18].visible">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.nextInspectionTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="气瓶制造单位" align="center" prop="manufacturingUnits" width="180"  v-if="columns[19].visible"/>
        <el-table-column label="充装气站" align="center" prop="fillingStation" width="180" v-if="columns[20].visible">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yh_gas_station" :value="scope.row.fillingStation"/>
          </template>
        </el-table-column>
        <el-table-column label="充装介质" align="center" prop="fillingMedium" width="180" v-if="columns[21].visible">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yh_medium" :value="scope.row.fillingMedium"/>
          </template>
        </el-table-column>
        <el-table-column label="充装时间" align="center" prop="note1" width="180" v-if="columns[22].visible">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.note1) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="充装压力" align="center" prop="fillingPressure" v-if="columns[23].visible"/>
        <el-table-column label="充装温度" align="center" prop="fillingTemperature" v-if="columns[24].visible"/>
        <el-table-column label="有无异常情况" align="center" prop="transportVehicles" width="180" v-if="columns[25].visible">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yh_anomalies" :value="scope.row.anomalies"/>
          </template>
        </el-table-column>
        <el-table-column label="运输车辆" align="center" prop="transportVehicles" v-if="columns[26].visible"/>

        <!--      <el-table-column label="用户ID" align="center" prop="userId" />
              <el-table-column label="单位ID" align="center" prop="deptId" />-->
        <el-table-column label="备注" align="center" prop="remark" v-if="columns[27].visible"/>
        <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="160">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['zzy:filling:edit']"
            >修改</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['zzy:filling:remove']"
            >删除
            </el-button>
            <el-button
              size="mini"
              type="text"
              @click="handleView(scope.row)"
              v-hasPermi="['zzy:filling:xiangqing']"
            >详细</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
    <!-- 添加或修改充装信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" append-to-body width="1300px">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">充装人信息</p>
            </el-divider>
          </el-header>

          <el-main>
            <!--第1行-->
            <el-row>
              <el-col :span="8">
                <el-form-item label="姓名" label-width="28%" prop="name">
                  <el-autocomplete
                    style="width:90%;float:left"
                    placeholder="请输入姓名"
                    v-model="form.name"
                    :fetch-suggestions="querySearchAsync1"
                    @select="handleSelect1"
                  >
                  </el-autocomplete>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="身份证号" label-width="28%" prop="idNumber">
                  <el-input v-model="form.idNumber" placeholder="请输入身份证号" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
<!--                <el-form-item label="工作单位" label-width="28%" prop="workPlace">
                  <el-select v-model="form.workPlace" placeholder="请选择工作单位" style="width:90%;float:left" clearable>
                    <el-option
                      v-for="dict in dict.type.yh_gas_station"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>-->
                <el-form-item label="性别" label-width="28%" prop="sex">
                  <el-select v-model="form.sex" placeholder="请选择性别" style="width:90%;float:left" clearable>
                    <el-option
                      v-for="dict in dict.type.sys_user_sex"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>

            <!--第2行-->
            <el-row>
              <el-col :span="8">
                <el-form-item label="工号" label-width="28%" prop="userName">
                  <el-input v-model="form.userName" placeholder="请输入工号" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="手机号" label-width="28%" prop="phone">
                  <el-input v-model="form.phone" label-width="28%" placeholder="请输入手机号" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="职位" label-width="28%" prop="posts">
                  <el-select v-model="form.posts"  placeholder="请选择职位" style="width:90%;float:left" clearable>
                    <el-option
                      v-for="dict in dict.type.yh_posts"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>

            <!--第3行-->
            <el-row>
              <el-col :span="8">
                <el-form-item label="出生日期" label-width="28%" prop="birth">
                  <el-date-picker clearable
                                  v-model="form.birth"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择出生日期" style="width:90%;float:left">
                  </el-date-picker>
                </el-form-item>
              </el-col>



              <!--                <el-col :span="8">
                              <el-form-item label="用户ID" label-width="28%" prop="userId">
                                <el-input v-model="form.userId" placeholder="请输入用户ID" style="width:90%;float:left"/>
                              </el-form-item>
                              </el-col>-->

            </el-row>

            <!--            <el-row>
                        <el-col :span="8">
                          <el-form-item label="单位ID" label-width="28%" prop="deptId">
                            <el-input v-model="form.deptId" placeholder="请输入单位ID" style="width:90%;float:left"/>
                          </el-form-item>
                        </el-col>
                        </el-row>-->

          </el-main>
        </el-container>

        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">气瓶信息</p>
            </el-divider>
          </el-header>

          <el-main>
            <!--第4行-->
            <el-row>
              <el-col :span="8">
                <el-form-item label="钢瓶瓶号" label-width="28%" prop="cylinderNumber">
                  <el-autocomplete
                    style="width:90%;float:left"
                    placeholder="请输入钢瓶瓶号"
                    v-model="form.cylinderNumber"
                    :fetch-suggestions="querySearchAsync"
                    @select="handleSelect"
                  >
                  </el-autocomplete>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="钢瓶状态" label-width="28%" prop="cylinderStatus">
                  <el-select v-model="form.cylinderStatus" placeholder="请选择钢瓶状态"  style="width:90%;float:left" clearable @change="showValue2()">
                    <el-option
                      v-for="dict in dict.type.yh_cylinder_status"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="应充介质" label-width="28%" prop="gasMedia" >
                  <el-select v-model="form.gasMedia" placeholder="请选择应充介质"  style="width:90%;float:left" clearable @change="showValue()">
                    <el-option
                      v-for="dict in dict.type.yh_medium"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>

            <!--第5行-->
            <el-row>
              <el-col :span="8">
                <el-form-item label="钢瓶重量" label-width="28%" prop="weight">
                  <el-input v-model="form.weight" placeholder="请输入钢瓶重量" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="钢瓶容积" label-width="28%" prop="volume">
                  <el-input v-model="form.volume" placeholder="请输入钢瓶容积" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
<!--                <el-form-item label="所属气站" label-width="28%" prop="belongingGasStation">
                  <el-select v-model="form.belongingGasStation" placeholder="请选择所属气站"  style="width:90%;float:left" clearable @change="showValue1()">
                    <el-option
                      v-for="dict in dict.type.yh_gas_station"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>-->
                <el-form-item label="钢瓶生产日期" label-width="28%" prop="manufactureDate">
                  <el-date-picker clearable
                                  v-model="form.manufactureDate"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择钢瓶生产日期" style="width:90%;float:left">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>

            <!--第6行-->
            <el-row>


              <el-col :span="8">
                <el-form-item label="钢瓶报废日期" label-width="28%" prop="scrapDate">
                  <el-date-picker clearable
                                  v-model="form.scrapDate"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择钢瓶报废日期" style="width:90%;float:left">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="气瓶检验时间" label-width="28%" prop="inspectionTime">
                  <el-date-picker clearable
                                  v-model="form.inspectionTime"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择气瓶检验时间" style="width:90%;float:left">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="下次检验时间" label-width="28%" prop="nextInspectionTime">
                  <el-date-picker clearable
                                  v-model="form.nextInspectionTime"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择下次检验时间" style="width:90%;float:left">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
<!--          第七行-->
            <el-row>
            <el-col :span="8">
              <el-form-item label="气瓶制造单位" label-width="28%" prop="manufacturingUnits">
                <el-input v-model="form.manufacturingUnits" placeholder="请输入气瓶制造单位" style="width:90%;float:left"/>
              </el-form-item>
            </el-col>
            </el-row>

          </el-main>
        </el-container>

        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">充装信息</p>
            </el-divider>
          </el-header>

          <el-main>
            <!--第一行-->
            <el-row>



              <el-col :span="8">
                <el-form-item label="充装介质" label-width="28%" prop="fillingMedium" >
                  <el-select v-model="form.fillingMedium" placeholder="请选择充装介质" style="width:90%;float:left" clearable @change="showValue()">
                    <el-option
                      v-for="dict in dict.type.yh_medium"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="充装时间" label-width="28%" prop="note1">
                  <el-date-picker clearable
                                  v-model="form.note1"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择充装时间" style="width:90%;float:left">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="8">
                <el-form-item label="充装压力" label-width="28%" prop="fillingPressure">
                  <el-input v-model="form.fillingPressure" placeholder="请输入充装压力" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="充装温度" label-width="28%" prop="fillingTemperature">
                  <el-input v-model="form.fillingTemperature" placeholder="请输入充装温度" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item label="有无异常情况" label-width="28%" prop="anomalies" >
                  <el-select v-model="form.anomalies" placeholder="请选择有无异常情况" style="width:90%;float:left" clearable @change="showValue()">
                    <el-option
                      v-for="dict in dict.type.yh_anomalies"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="8">
                <el-form-item label="运输车辆" label-width="28%" prop="transportVehicles">
                  <el-input v-model="form.transportVehicles" placeholder="请输入运输车辆" style="width:90%;float:left"/>
                </el-form-item>
              </el-col>
              </el-row>

            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" label-width="9%" prop="remark">
                  <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" style="width:97.3%;float:left"/>
                </el-form-item>
              </el-col>
            </el-row>

          </el-main>
        </el-container>

      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listFilling, getFilling, delFilling, addFilling, updateFilling } from "@/api/module/zzy/filling";
import {listCylinders} from "@/api/module/zzy/cylinders";
import {listBaseinfo} from "@/api/module/zzy/baseinfo";
export default {
  name: "Filling",
  dicts: ['sys_job_status', 'sys_job_group', 'sys_user_sex','yh_gas_station','yh_posts','yh_cylinder_status','yh_medium','yh_anomalies'],
  data() {
    return {
      // 基础信息表格数据
      cylindersList: [],
      baseinfoList: [],
      // 遮罩层
      columns: [
        {key: 0, label: `序号`, visible: true},
        {key: 1, label: `姓名`, visible: true},
        {key: 2, label: `身份证号`, visible: false},
        {key: 3, label: `工作单位`, visible: true},
        {key: 4, label: `性别`, visible: false},
        {key: 5, label: `工号`, visible: false},
        {key: 6, label: `手机号`, visible: false},
        {key: 7, label: `职位`, visible: false},
        {key: 8, label: `出生日期`, visible: false},
        {key: 9, label: `钢瓶瓶号`, visible: true},
        {key: 10, label: `应充介质`, visible: false},
        {key: 11, label: `钢瓶状态`, visible: true},
        {key: 12, label: `钢瓶重量`, visible: false},
        {key: 13, label: `钢瓶容积`, visible: false},
        {key: 14, label: `所属气站`, visible: true},
        {key: 15, label: `钢瓶生产日期`, visible: false},
        {key: 16, label: `钢瓶报废日期`, visible: false},
        {key: 17, label: `气瓶检验时间`, visible: true},
        {key: 18, label: `下次检验时间`, visible: true},
        {key: 19, label: `气瓶制造单位`, visible: true},
        {key: 20, label: `充装气站`, visible: true},
        {key: 21, label: `充装介质`, visible: true},
        {key: 22, label: `充装时间`, visible: true},
        {key: 23, label: `充装压力`, visible: true},
        {key: 24, label: `充装温度`, visible: true},
        {key: 25, label: `有无异常情况`, visible: true},
        {key: 26, label: `运输车辆`, visible: true},
        {key: 27, label: `备注`, visible: true},
      ],
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 充装信息表格数据
      fillingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        idNumber: null,
        workPlace: null,
        sex: null,
        userName: null,
        phone: null,
        posts: null,
        birth: null,
        cylinderNumber: null,
        cylinderStatus: null,
        gasMedia: null,
        weight: null,
        volume: null,
        belongingGasStation: null,
        manufactureDate: null,
        scrapDate: null,
        fillingStation: null,
        fillingMedium: null,
        fillingTime: null,
        userId: null,
        deptId: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        orderByColumn:"note1",
        isAsc:"desc"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
          {required: true, message: "姓名不能为空", trigger: "blur"},
        ],
        /*workPlace: [
          {required: true, message: "工作单位不能为空", trigger: "blur"},
        ],*/
        userName: [
          {required: true, message: "工号不能为空", trigger: "blur"},
        ],
        idNumber: [
          {required: true,message: "身份证号不能为空",trigger: "blur"}
        ],
        sex: [
          {required: true, message: "性别不能为空", trigger: "blur"},
        ],

        phone: [
          {required: true, message: "电话不能为空", trigger: "blur"},
        ],
        cylinderNumber: [
          {required: true, message: "瓶号不能为空", trigger: "blur"},
        ],
        gasMedia: [
          {required: true, message: "应充介质不能为空", trigger: "blur"},
        ],
        cylinderStatus: [
          {required: true, message: "钢瓶状态不能为空", trigger: "blur"},
        ],
        weight: [
          {required: true, message: "钢瓶重量不能为空", trigger: "blur"},
        ],
        volume: [
          {required: true, message: "钢瓶容积不能为空", trigger: "blur"},
        ],
       /* belongingGasStation: [
          {required: true, message: "所属气站不能为空", trigger: "blur"},
        ],*/
        manufactureDate: [
          {required: true, message: "钢瓶生产日期不能为空", trigger: "blur"},
        ],
        scrapDate: [
          {required: true, message: "钢瓶报废日期不能为空", trigger: "blur"},
        ],
        inspectionTime: [
          {required: true, message: "气瓶检验时间不能为空", trigger: "blur"},
        ],
        nextInspectionTime: [
          {required: true, message: "下次检验时间不能为空", trigger: "blur"},
        ],
      /*  fillingStation:[
          {required: true, message: "充装气站不能为空", trigger: "blur"},
        ],*/
        manufacturingUnits: [
          {required: true, message: "气瓶制造单位不能为空", trigger: "blur"},
        ],
        fillingMedium:[
          {required: true, message: "充装介质不能为空", trigger: "blur"},
        ],
        note1:[
          {required: true, message: "充装时间不能为空", trigger: "blur"},
        ],
        fillingPressure: [
          {required: true, message: "充装压力不能为空", trigger: "blur"},
        ],
        fillingTemperature: [
          {required: true, message: "充装温度不能为空", trigger: "blur"},
        ],
        anomalies: [
          {required: true, message: "有无异常情况不能为空", trigger: "blur"},
        ],
        transportVehicles: [
          {required: true, message: "运输车辆不能为空", trigger: "blur"},
        ],
      }
    };
  },
  created() {
    this.getList();
    /*this.getCylinders();
    this.getBaseinfo();*/
  },
  methods: {
    getCylinders() {
      listCylinders().then(response => {
        this.cylindersList = response.rows;

      });

    },
    getBaseinfo() {
      listBaseinfo().then(response => {
        this.baseinfoList = response.rows;

      });

    },
    //queryString 为在框中输入的值
    //cb 回调函数，将处理好的数据推回
    querySearchAsync(queryString, cb) {
      //因为autocomplete只识别value字段,所以用replace(/需要用的字段/g,"value")，将需要用的字段全部替换成value
      //(/***/g 是全部替换，如果不用全部替换，可以参考https://www.w3school.com.cn/jsref/jsref_replace.asp)
      let cylindersJson= JSON.parse(JSON.stringify(this.cylindersList).replace(/cylinderNumber/g,"value"));
      let results = queryString ? cylindersJson.filter(this.createStateFilter(queryString)) : cylindersJson;
      clearTimeout(this.timeout);
      this.timeout = setTimeout(() => {
        cb(results);
      }, 0.5*1000);
    },
    //根据输入的字段进行筛选
    createStateFilter(queryString) {
      return (state) => {
        return (state.value.toString().toLowerCase().indexOf(queryString.toLowerCase()) === 0);
      };
    },
    querySearchAsync1(queryString, cb) {
      //因为autocomplete只识别value字段,所以用replace(/需要用的字段/g,"value")，将需要用的字段全部替换成value
      //(/***/g 是全部替换，如果不用全部替换，可以参考https://www.w3school.com.cn/jsref/jsref_replace.asp)
      let baseinfoJson= JSON.parse(JSON.stringify(this.baseinfoList).replace(/name/g,"value"));
      let results = queryString ? baseinfoJson.filter(this.createStateFilter1(queryString)) : baseinfoJson;
      clearTimeout(this.timeout);
      this.timeout = setTimeout(() => {
        cb(results);
      }, 0.5*1000);
    },
    //根据输入的字段进行筛选
    createStateFilter1(queryString) {
      return (state) => {
        return (state.value.toString().toLowerCase().indexOf(queryString.toLowerCase()) === 0);
      };
    },

//将其他数据自动补全，采用覆盖的方法
    handleSelect(item){

      this.form.cylinderNumber=item.value;
      this.form.gasMedia=item.gasMedia;
      this.form.cylinderStatus=item.cylinderStatus;
      this.form.weight=item.weight;
      this.form.volume=item.volume;
      this.form.belongingGasStation=item.belongingGasStation;
      this.form.manufactureDate=item.manufactureDate;
      this.form.scrapDate=item.scrapDate;

    },
    handleSelect1(item){
      this.form.name = item.value;
      this.form.idNumber=item.idNumber;
      this.form.certificateId=item.certificateId;
      this.form.workPlace=item.workPlace;
      this.form.sex=item.sex;
      this.form.userName=item.userName;
      this.form.phone=item.phone;
      this.form.posts=item.posts;
      this.form.birth=item.birth;

    },
    /** 查询充装信息列表 */
    getList() {
      this.loading = true;
      listFilling(this.queryParams).then(response => {
        this.fillingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        idNumber: null,
        workPlace: null,
        sex: null,
        userName: null,
        phone: null,
        posts: null,
        birth: null,
        cylinderNumber: null,
        cylinderStatus: null,
        gasMedia: null,
        weight: null,
        volume: null,
        belongingGasStation: null,
        manufactureDate: null,
        scrapDate: null,
        fillingStation: null,
        fillingMedium: null,
        fillingTime: null,
        userId: null,
        deptId: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.names = selection.map(item => item.name)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加充装信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getFilling(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改充装信息";
      });
    },
    indexMethod(index) {
      index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
      return index
    },
    showValue(){
      let a = this.form.gasMedia
      let b = this.form.fillingMedium
      if (a==null || b==null || a==b){

        return true
      }
      else {
        this.$modal.msgWarning("应充介质与充装介质不一致");
        return false
      }


    },
    showValue1(){
      let a = this.form.belongingGasStation
      let b = this.form.fillingStation
      if (a==null || b==null || a==b){

        return true
      }
      else {
        this.$modal.msgWarning("所属气站与充装气站不一致");
        return false
      }


    },
    showValue2(){
      let a = this.form.cylinderStatus
      if (a==1){
        this.$modal.msgWarning("钢瓶状态为报废，无法充装介质");
        return false
      }
      else {
        return true
      }


    },
    close() {
      this.$tab.closePage();
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid & this.showValue()==true & this.showValue1()==true& this.showValue2()==true) {
          if (this.form.id != null) {
            updateFilling(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addFilling(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      const name = row.name || this.names;
      this.$modal.confirm('是否确认删除充装信息名字为"' + name + '"的数据项？').then(function() {
        return delFilling(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    handleView(row) {
      const id = row.id;
      this.$router.push({ path:"/qiping/zzyxx", query: {id}});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('zzy/filling/export', {
        ...this.queryParams
      }, `filling_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
